import request from '@/utils/request'

/**
 * 优惠券列表
 */
export function getShopCouponList(params: Record<string, any>) {
    // return request.get(`shop/coupon`, params)
    return request.get(`promotion/coupon-template/page`, params, { isYuDao: true })

}
// 获得优惠劵模版列表
export function getCouponTemplateList(params: Record<string, any>) {
    // return request.get(`shop/coupon`, params)
    return request.get(`promotion/coupon-template/list`, params, { isYuDao: true })

}

/**
 * 优惠券详情
 */
export function getShopCouponInfo(id: number) {
    // return request.get(`shop/coupon/${id}`)
    return request.get(`promotion/coupon-template/get?id=${id}`, {}, { isYuDao: true })


}

/**
 * 优惠券二维码
 */
export function getShopCouponQrocde(id: number) {
    return request.get(`shop/coupon/qrcode/${id}`)
}

/**
 * 领取优惠券
 */
export function getCoupon(params: Record<string, any>) {
    // return request.post(`shop/coupon`, params, { showSuccessMessage: true })
    return request.post(`promotion/coupon/take`, params, { showSuccessMessage: true, isYuDao: true })

}

/**
 * 获取我的优惠券
 */
export function getMyCouponList(params: Record<string, any>) {
    // return request.get(`shop/member/coupon`, params)
    return request.get(`promotion/coupon/page`, params, { isYuDao: true })
}

/**
 * 获取优惠券列表供组件调用
 */
// export function getShopCouponComponents(params: Record<string, any>) {
//     return request.get(`shop/coupon/components`, params)
// }
export function getShopCouponComponents(params: Record<string, any>) {
    return request.get(`promotion/coupon-template/list-by-ids`, params, { isYuDao: true })
}
/**
 * 获取我的优惠券数量
 * status 1：待使用，2：已使用，3已失效
 */
export function getMyCouponCount(params: Record<string, any>) {
    return request.get(`shop/member/coupon/count`, params)
}
// 获得未使用的优惠劵数量
export function getUnusedCouponCount() {
    return request.get(`promotion/coupon/get-unused-count`, {}, { isYuDao: true })
}
/**
 * 获取我的优惠券类型
 */
export function getMyCouponType() {
    return request.get(`shop/coupon_type`)
}
/**
 * 获取我的优惠数量
 * 未使用的优惠劵数量
 */
export function getMyCouponStatusCount() {
    // return request.get(`shop/member/coupon/status_count`)
    return request.get(`promotion/coupon/get-unused-count`, {}, { isYuDao: true })

}